/**
 * Created by zlj on 2017/1/14.
 */
require("jquery");
require('layout/util');
var $alert = require('libs/alert');

$(function () {
    judgeUpdateOrAdd();

    $("#resource_back").on("click",function () {
        window.history.back();
    });

});


function judgeUpdateOrAdd() {
    var url = window.location.href;
    if(url.indexOf("id=")>0){
        var id = $.getUrlParam('id');
        load(id);
    }
}

function load(id) {
    $.ajax({
        url:'api/v1/p/mms/authResource/load',
        type:'post',
        data:{id:id},
        dataType:'json',
        success:function (result) {
            if(result.code == 200){
                $("#resource_form").setForm(result.data);
                $("#resource_form input").attr("disabled",true);
                $("#resource_form select").attr("disabled",true);
            }else{
                $alert(result.message);
            }
        },
        error:function () {
            console.error('接口: api/v1/p/mms/authResource/load 失败')
        }
    })
}